<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ForumCategory extends Model
{
    protected $table = 'forum_categories';
    protected $fillable = [
        'id','name', 'description','post_count','displayorder',
    ];
    protected $hidden=[];
    public function setIconAttribute($path)
    {
        // 如果不是 `http` 子串开头，那就是从后台上传的，需要补全 URL
        if ( ! starts_with($path, 'http')) {

            // 拼接完整的 URL
            $path = config('app.url') . "/Uploads/images/forum_category/$path";
        }

        $this->attributes['icon'] = $path;
    }
}
